<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of DefaultController
 *
 * @author Zelic
 */
class ZF_DefaultController extends Zend_Controller_Action {
    public function init(){
    	
		$module = $this->_request->getModuleName();
		$this->view->module = $module;
		$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
		$this->view->baseUrl = $baseUrl;
                $auth = Zend_Auth::getInstance();
                if ($auth->hasIdentity()) {
                   $data = $auth->getStorage()->read();
                    
                    $this->view->profileNameSpace = (array)$data ;
                    
                }                                            
		$option = array("layout"=>"index", "layoutPath"=>APPLICATION_PATH."/modules/default/layouts/scripts", "module"=>"default");
		Zend_Layout::startMvc($option);
		$this->view->profileNameSpace = null;
    }
     public function changeRouter($request,$map)
    {
     
      $configs = new Zend_Config_Ini(APPLICATION_PATH.'/configs/routers.ini','config',true);
      $configs->routes->index->defaults = array(
         "module" =>$request['module'],
         "controller" =>$request['controller'],
         "action"   => $request['action'],
      );
   
      $configs->routes->index->map = $map;
      
      $write = new Zend_Config_Writer_Ini();
      $write->write(APPLICATION_PATH.'/configs/routers.ini',$configs);
   


    }
}

?>
